<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
This tests that select all works in a readonly textarea, without selecting the
surrounding text.
<br>
<textarea id="sample" readonly>This text should be selected</textarea>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var textarea = document.getElementById('sample');
    textarea.focus();
    var isMac = navigator.platform.indexOf('Mac') == 0;
    document.execCommand('selectAll');
    assert_equals(selection.anchorNode, document.body, 'anchorNode');
    assert_equals(selection.anchorOffset, 3, 'anchorOffset');
    assert_equals(selection.focusNode, document.body, 'focusNode');
    assert_equals(selection.focusOffset, 3, 'focusOffset');
    assert_equals(textarea.selectionStart, 0, 'textarea.selectionStart');
    assert_equals(textarea.selectionEnd, 28, 'textarea.selectionEnd');
    assert_equals(textarea.selectionDirection, isMac ? 'none' : 'forward', 'textarea.selectionDirection');
}, 'readonly textarea is select-able');
</script>
